package com.automannn.springPractice.applicationContext.bean.init;

import com.automannn.springPractice.applicationContext.bean.factory.UserFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class GarbageGcBean {
    public static void main(String[] args) throws InterruptedException {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
        context.register(InitBeanCreateBean.class);
        context.refresh();
        System.out.println("启动上下文");
        UserFactory userFactory = context.getBean(UserFactory.class);
        System.out.println(userFactory);
        System.out.println("上下文准备关闭");
        context.close();
        System.out.println("上下文关闭成功");
        Thread.sleep(5000);
        System.gc();
        Thread.sleep(5000);
    }
}
